package Servlet.Order;

import DataBase.DataBase;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class AddOrderServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //清空用户购物车，生成一个订单
        HttpSession HS = req.getSession();
        String username = HS.getAttribute("username").toString();
        DataBase.addOrderInfo(username);
        HS.setAttribute("CartPetInfo",null);
        resp.sendRedirect("GetOrderInfoServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }
}
